package battlecruiser.game;

import battlecruiser.player.Player;
import org.apache.log4j.Logger;

import java.io.IOException;

/**
 * @author Yakiv Tymoshenko
 * @since 02.09.12
 */
public class Game {

    private static Logger LOG = Logger.getLogger(Game.class);

    private Player player1;
    private Player player2;

    public Game(Player player1, Player player2) {
        this.player1 = player1;
        this.player2 = player2;
    }

    // Prepare player1's and player2's fleets
    // TODO add 2 parallel threads
    public void start() throws IOException {
        while (!player1.isDefeated() && !player2.isDefeated()) {
            player1.shoot();
            LOG.debug("Player \"" + player1.getName() + "\" dashboard: ");
            LOG.debug("Own board: \n" + player1.getObservableBoard());
            LOG.debug("Enemy board: \n" + player1.getObserverBoard());
            LOG.debug("Player \"" + player2.getName() + "\" dashboard: ");
            LOG.debug("Own board: \n" + player2.getObservableBoard());
            LOG.debug("Enemy board: \n" + player2.getObserverBoard());
//            player2.shoot();
        }
    }

    public Player getPlayer1() {
        return player1;
    }

    public Player getPlayer2() {
        return player2;
    }
}
